//
//  ViewController.m
//  mainpage
//
//  Created by John Zheng on 2018/5/9.
//  Copyright © 2018年 John Zheng. All rights reserved.
//

#import "ViewController.h"
#import "space_view.h"
#import "map/mainMap.h"

@interface ViewController ()
@property(nonatomic,strong) UINavigationController *navi;
@property(nonatomic,strong) NSArray* SOS_number;

@end

@implementation ViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    //控制图片位置
    typedef struct UIEdgeInsets {
        CGFloat top, left, bottom, right; // specify amount to inset (positive) for each of the edges. values can be negative to 'outset'
    } UIEdgeInsets;
    
    //MARK:用户名标签
    UILabel* user_name = [[UILabel alloc]init];
    user_name.text = @"USRername";
    user_name.frame = CGRectMake(110, 110, 200, 45);
    user_name.backgroundColor = [UIColor whiteColor];
    user_name.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:user_name];
    
    
    //MARK:头像按钮
    head = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    head.frame = CGRectMake(20, 70, 80, 80);
    head.backgroundColor = [UIColor whiteColor];
    head.layer.masksToBounds = YES;
    head.layer.borderWidth = 2;
    head.layer.borderColor = [UIColor blackColor].CGColor;
    head.layer.cornerRadius = 40;
    [head addTarget:self action:@selector(clickBtn_head) forControlEvents:UIControlEventTouchUpInside];
    [head setBackgroundImage:[UIImage imageNamed:@"头像"]  forState:UIControlStateNormal];
    
    //MARK:定位按钮
    position =[UIButton buttonWithType:UIButtonTypeRoundedRect];
    position.frame = CGRectMake(16, 190, 170, 100);
    position.backgroundColor =[UIColor whiteColor];
    position.layer.masksToBounds =YES;
    position.layer.cornerRadius = 15;
    [position setBackgroundImage:[UIImage imageNamed:@"定位"] forState:UIControlStateNormal];
    [position setTitle:@"定位" forState:UIControlStateNormal];
    [position setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    position.imageEdgeInsets = UIEdgeInsetsMake(0, position.titleLabel.bounds.size.width, 0, -position.titleLabel.bounds.size.width);
    [position addTarget:self action:@selector(selectBtn_map) forControlEvents:UIControlEventTouchUpInside];
    
    
    //MARK:导航按钮
    GPS =[UIButton buttonWithType:UIButtonTypeRoundedRect];
    GPS.frame = CGRectMake(199, 190, 170, 100);
    GPS.backgroundColor =[UIColor whiteColor];
    GPS.layer.masksToBounds =YES;
    GPS.layer.cornerRadius = 15;
    [GPS setTitle:@"导航" forState:UIControlStateNormal];
    [GPS setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    [GPS setBackgroundImage:[UIImage imageNamed:@"导航"] forState:UIControlStateNormal];
    
    //MARK:电台按钮
    radio=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    radio.frame = CGRectMake(16, 300, 170, 100);
    radio.backgroundColor =[UIColor whiteColor];
    radio.layer.masksToBounds =YES;
    radio.layer.cornerRadius = 15;
    [radio setTitle:@"电台" forState:UIControlStateNormal];
    [radio setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    [radio setBackgroundImage:[UIImage imageNamed:@"电台"] forState:UIControlStateNormal];
    
    //MARK:动态按钮
    dynamic =[UIButton buttonWithType:UIButtonTypeRoundedRect];
    dynamic.frame = CGRectMake(199, 300, 170, 100);
    dynamic.backgroundColor =[UIColor whiteColor];
    dynamic.layer.masksToBounds =YES;
    dynamic.layer.cornerRadius = 15;
    [dynamic setTitle:@"动态" forState:UIControlStateNormal];
    [dynamic setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    [dynamic setBackgroundImage:[UIImage imageNamed:@"动态"] forState:UIControlStateNormal];
    
    //MARK:测试按钮
    exam=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    exam.frame = CGRectMake(16, 410, 170, 100);
    exam.backgroundColor =[UIColor whiteColor];
    exam.layer.masksToBounds =YES;
    exam.layer.cornerRadius = 15;
    [exam setTitle:@"测试" forState:UIControlStateNormal];
    [exam setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    [exam setBackgroundImage:[UIImage imageNamed:@"测试"] forState:UIControlStateNormal];
    
    //MARK:空间按钮
    space=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    space.frame = CGRectMake(199, 410, 170, 100);
    space.backgroundColor =[UIColor whiteColor];
    space.layer.masksToBounds =YES;
    space.layer.cornerRadius = 15;
    [space setTitle:@"动态" forState:UIControlStateNormal];
    [space setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    [space setBackgroundImage:[UIImage imageNamed:@"动态"] forState:UIControlStateNormal];
    [space addTarget:self action:@selector(clickBtn_space) forControlEvents:UIControlEventTouchUpInside];
    
    //MARK:求救按钮
    SOS = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    SOS.frame = CGRectMake(123, 530, 150, 120);
    SOS.backgroundColor = [UIColor whiteColor];
    SOS.layer.masksToBounds = YES;
    SOS.layer.borderWidth = 2.0;
    SOS.layer.borderColor = [UIColor blackColor].CGColor;
    SOS.layer.cornerRadius = 40;
    [SOS addTarget:self action:@selector(clickBtn_SOS) forControlEvents:UIControlEventTouchUpInside];
    [SOS setTitle:@"呼救" forState:UIControlStateNormal];
    [SOS setTitleColor:[UIColor clearColor]forState:UIControlStateNormal];
    [SOS setBackgroundImage:[UIImage imageNamed:@"呼救"] forState:UIControlStateNormal];
    _SOS_number = [[NSArray alloc]initWithObjects:@"10086", nil];
    
    
    
    
    [self.view addSubview:head];
    [self.view addSubview:position];
    [self.view addSubview:radio];
    [self.view addSubview:GPS];
    [self.view addSubview:dynamic];
    [self.view addSubview:space];
    [self.view addSubview:exam];
    [self.view addSubview:SOS];
    
}

- (void)clickBtn_head
{
    
}

- (void)clickBtn_space
{
    space_view* space = [[space_view alloc]init];
    [self.navigationController pushViewController:space animated:YES];
}
- (void)selectBtn_map{
    mainMap *map = [[mainMap alloc]init];
    [self.navigationController pushViewController:map animated:YES];
    
}


- (void)clickBtn_SOS
{
    
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_SOS_number[0]];
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self.view addSubview:callWebview];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
